package com.iweb.newa202104.exception;


import com.iweb.newa202104.util.CommonUtil;
import com.iweb.newa202104.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;

import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: LGZ
 * @Date: 2021/2/4 14:39
 * @Description:
 */
@Slf4j
@ControllerAdvice
public class HttpMessageNotReadableExceptionHandler {
    @ExceptionHandler(value = HttpMessageNotReadableException.class)
    @ResponseBody
    public ResultVO error(HttpMessageNotReadableException e) {
        log.error("前端传入数据异常");
        return CommonUtil.ajaxReturn(400, "参数异常");
    }
}
